/**
 * 
 */
package cu.ds.logicalsync.fytasrealm.util;

import java.io.File;

import javax.swing.JOptionPane;

/**
 * UI based tool - mainly using for value inspection in Service and Application
 * level contains some method related to JXTA
 * 
 * @author r.vashira
 */
public class Tools {
	public static void popInformationMsg(String Name, String Message) {
		JOptionPane.showMessageDialog(null, Message, Name,
				JOptionPane.INFORMATION_MESSAGE);
	}

	public static void popErrorMsg(String Name, String Message) {
		JOptionPane.showMessageDialog(null, Message, Name,
				JOptionPane.ERROR_MESSAGE);
	}

	public static void popWarningMsg(String Name, String Message) {
		JOptionPane.showMessageDialog(null, Message, Name,
				JOptionPane.WARNING_MESSAGE);
	}

	public static int popYesNoQuestion(String Name, String Question) {
		return JOptionPane.showConfirmDialog(null, Question, Name,
				JOptionPane.YES_NO_OPTION);
	}

	public static void deleteConfigurationInDefaultHome() {
		String DefaultHome = "." + File.separator + ".jxta";
		Tools.recursiveDelete(new File(DefaultHome));
	}

	public static void recursiveDelete(File TheFile) {
		File[] SubFiles = TheFile.listFiles();
		if (SubFiles != null) {
			for (int i = 0; i < SubFiles.length; i++) {
				if (SubFiles[i].isDirectory()) {
					recursiveDelete(SubFiles[i]);
				}
				SubFiles[i].delete();
			}
			TheFile.delete();
		}
	}
}
